public class GumballMachine{

	State soldout;
	State noQuarter;
	State hasQuarter;
	State solState;
	State state = soldout;
	int count=0;
	public GumballMachine(int numberGumballs){
		soldout = new SoldOutState(this);
		//noQuarter = new NoQuarterState(this);
		//hasQuarter = new HasQuarterState(this);
		this.count = numberGumballs;
		if(numberGumballs>0){
		state = soldout;
		}
	}
	public void insertQuarter(){
		state.insertQuarter();
	}
	public void ejectQuarter(){
		state.ejectQuarter();
	}
	public void turnCrank(){
		state.turnCrank();
		state.dispense();
	}
	void setState(State state){
	this.state = state;
	}
	
	void releaseBall(){
	System.out.println("A Gumball comes rolling out the slot...");
	if(count!=0){
	count = count -1;
	}
	}
}

